<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Push Hexo to your own server | Cying</title><meta name="keywords" content="NodeJs"><meta name="author" content="Cying-承影"><meta name="copyright" content="Cying-承影"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="之前我的 hexo 博客都是部署在 github 上，但是偶尔会访问不到，并且会有访问速度慢等问题，在前几天学完 docker 和 nginx 之后呢，自己尝试了一下部署到自己的服务器，发现成功了，特分享一下操作流程 我们知道 hexo 挂在 Github 的仓库中，仓库里有如下内容这个目录结构和 hexo 编译出来的 public 文件夹其实是一样的 我们只需要把这个目录上传到我们的服务器即可，">
<meta property="og:type" content="article">
<meta property="og:title" content="Push Hexo to your own server">
<meta property="og:url" content="http://cyingk.github.io/2020/08/07/Hexo-To-Own-Server/index.html">
<meta property="og:site_name" content="Cying">
<meta property="og:description" content="之前我的 hexo 博客都是部署在 github 上，但是偶尔会访问不到，并且会有访问速度慢等问题，在前几天学完 docker 和 nginx 之后呢，自己尝试了一下部署到自己的服务器，发现成功了，特分享一下操作流程 我们知道 hexo 挂在 Github 的仓库中，仓库里有如下内容这个目录结构和 hexo 编译出来的 public 文件夹其实是一样的 我们只需要把这个目录上传到我们的服务器即可，">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://gitee.com/CyingK/files/raw/master/images/Cying/hexo.jpg">
<meta property="article:published_time" content="2020-08-07T07:06:35.000Z">
<meta property="article:modified_time" content="2020-08-09T04:11:13.132Z">
<meta property="article:author" content="Cying-承影">
<meta property="article:tag" content="NodeJs">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/CyingK/files/raw/master/images/Cying/hexo.jpg"><link rel="shortcut icon" href="/img/favicon.ico"><link rel="canonical" href="http://cyingk.github.io/2020/08/07/Hexo-To-Own-Server/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//www.clarity.ms"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>(function(c,l,a,r,i,t,y){
    c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
    t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
    y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "4zndahq92q");</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: 'days',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"Traditional Chinese Activated Manually","cht_to_chs":"Simplified Chinese Activated Manually","day_to_night":"Dark Mode Activated Manually","night_to_day":"Light Mode Activated Manually","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isanchor: false
};

const saveToLocal = {
  // ttl 單位是 天
  set: function setWithExpiry(key, value, ttl) {
    if (ttl === 0) return
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}

// https://stackoverflow.com/questions/16839698/jquery-getscript-alternative-in-native-javascript
const getScript = url => new Promise((resolve, reject) => {
  const script = document.createElement('script')
  script.src = url
  script.async = true
  script.onerror = reject
  script.onload = script.onreadystatechange = function() {
    const loadState = this.readyState
    if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
    script.onload = script.onreadystatechange = null
    resolve()
  }
  document.head.appendChild(script)
})</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2020-08-09 12:11:13'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = '1'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}const fontSizeVal = saveToLocal.get('global-font-size')
if (fontSizeVal !== undefined) {
  document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
}})()</script><meta name="generator" content="Hexo 5.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">Loading...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="/img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">23</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">Tags</div><div class="length-num">12</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">Categories</div><div class="length-num">3</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fa fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> Categories</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://5b0988e595225.cdn.sohucs.com/images/20190831/84729f5c5bb346208416445feb485df6.jpeg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Cying</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fa fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> Categories</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Push Hexo to your own server</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2020-08-07T07:06:35.000Z" title="Created 2020-08-07 15:06:35">2020-08-07</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2020-08-09T04:11:13.132Z" title="Updated 2020-08-09 12:11:13">2020-08-09</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Blog/">Blog</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">Word count:</span><span class="word-count">713</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">Reading time:</span><span>2min</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><html><head></head><body><p>之前我的 hexo 博客都是部署在 github 上，但是偶尔会访问不到，并且会有访问速度慢等问题，在前几天学完 <code>docker</code> 和 <code>nginx</code> 之后呢，自己尝试了一下部署到自己的服务器，发现成功了，特分享一下操作流程</p>
<p>我们知道 <code>hexo</code> 挂在 <code>Github</code> 的仓库中，仓库里有如下内容<br><a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20200807135026717.png#pic_center" data-fancybox="group" data-caption="在这里插入图片描述" class="fancybox"><img alt="在这里插入图片描述" title="在这里插入图片描述" data-src="https://img-blog.csdnimg.cn/20200807135026717.png#pic_center" class="lazyload"></a><br>这个目录结构和 <code>hexo</code> 编译出来的 <code>public</code> 文件夹其实是一样的</p>
<p><a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20200807135155743.png#pic_center" data-fancybox="group" data-caption="在这里插入图片描述" class="fancybox"><img alt="在这里插入图片描述" title="在这里插入图片描述" data-src="https://img-blog.csdnimg.cn/20200807135155743.png#pic_center" class="lazyload"></a><br>我们只需要把这个目录上传到我们的服务器即可，可以选择 <code>nginx</code> 做静态资源映射，也可以使用 <code>Tomcat</code> 的 <code>webapps</code>，这里就演示一下 <code>nginx</code> 吧，直接从 <code>docker</code> 上拉一个</p>
<h1 id="1、前期准备"><a href="#1、前期准备" class="headerlink" title="1、前期准备"></a>1、前期准备</h1><div class="code-area-wrap"><div class="highlight-tools"><i class="fa fa-angle-down code-expand" aria-hidden="true"></i><div class="code_lang">bash</div></div><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p /usr/doc/nginx/hexo/public</span><br><span class="line"><span class="built_in">cd</span> /usr/doc/nginx</span><br><span class="line">vim nginx.conf</span><br></pre></td></tr></tbody></table></figure></div>
<p><strong>nginx.conf</strong> 的内容：</p>
<div class="code-area-wrap"><div class="highlight-tools"><i class="fa fa-angle-down code-expand" aria-hidden="true"></i><div class="code_lang">Code</div></div><figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">user  nginx;</span><br><span class="line">worker_processes  1;</span><br><span class="line"></span><br><span class="line">error_log   /var/log/nginx/error.log warn;</span><br><span class="line">pid         /var/run/nginx.pid;</span><br><span class="line"></span><br><span class="line">events {</span><br><span class="line">    worker_connections  1024;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">http {</span><br><span class="line">    include         /etc/nginx/mime.types;</span><br><span class="line">    default_type    application/octet-stream;</span><br><span class="line">    log_format  main    '$remote_addr - $remote_user [$time_local] "$request" '</span><br><span class="line">                        '$status $body_bytes_sent "$http_referer" '</span><br><span class="line">                        '"$http_user_agent" "$http_x_forwarded_for"';</span><br><span class="line">    access_log  /var/log/nginx/access.log  main;</span><br><span class="line">    sendfile        on;</span><br><span class="line">    #tcp_nopush     on;</span><br><span class="line">    keepalive_timeout   65;</span><br><span class="line">    #gzip   on;</span><br><span class="line">    server {</span><br><span class="line">        listen 80;</span><br><span class="line">        server_name 192.168.164.128;</span><br><span class="line">        location / {</span><br><span class="line">            root    /usr/share/nginx/hexo;</span><br><span class="line">        }</span><br><span class="line">    }</span><br><span class="line">    include /etc/nginx/conf.d/*.conf;</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure></div>
<h1 id="2、容器初始化（请先安装-docker）"><a href="#2、容器初始化（请先安装-docker）" class="headerlink" title="2、容器初始化（请先安装 docker）"></a>2、容器初始化（请先安装 docker）</h1><h2 id="2-1、拉取镜像"><a href="#2-1、拉取镜像" class="headerlink" title="2.1、拉取镜像"></a>2.1、拉取镜像</h2><div class="code-area-wrap"><div class="highlight-tools"><i class="fa fa-angle-down code-expand" aria-hidden="true"></i><div class="code_lang">bash</div></div><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull nginx</span><br></pre></td></tr></tbody></table></figure></div>
<h2 id="2-2、创建容器"><a href="#2-2、创建容器" class="headerlink" title="2.2、创建容器"></a>2.2、创建容器</h2><div class="code-area-wrap"><div class="highlight-tools"><i class="fa fa-angle-down code-expand" aria-hidden="true"></i><div class="code_lang">bash</div></div><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">docker run -d\</span><br><span class="line"> -p 81:80\</span><br><span class="line"> -e TZ=<span class="string">"Asia/Shanghai"</span>\</span><br><span class="line"> --restart=always\</span><br><span class="line"> --name nginx\</span><br><span class="line"> -v /usr/doc/nginx/nginx.conf:/etc/nginx/nginx.conf\</span><br><span class="line"> -v /usr/doc/nginx/hexo/public:/usr/share/nginx/hexo\</span><br><span class="line"> nginx</span><br><span class="line">-----------------------------------------------------</span><br><span class="line"><span class="comment"># 说明</span></span><br><span class="line">	<span class="comment"># -p 指定暴露的端口，{暴露端口}:{容器内部端口}</span></span><br><span class="line">	<span class="comment"># -e TZ 指定时区</span></span><br><span class="line">	<span class="comment"># --restart 服务器重启后可自动启动</span></span><br><span class="line">	<span class="comment"># --name 容器名</span></span><br><span class="line">	<span class="comment"># -v /usr/doc/nginx/nginx.conf:/etc/nginx/nginx.conf</span></span><br><span class="line">	<span class="comment">#	 将服务器的 /usr/doc/nginx/nginx.conf 挂载到容器的 /etc/nginx/nginx.conf</span></span><br><span class="line">	<span class="comment"># -v /usr/doc/nginx/hexo/public:/usr/share/nginx/hexo</span></span><br><span class="line">	<span class="comment">#	 将服务器的 /usr/doc/nginx/hexo/public 挂载到容器的 /usr/share/nginx/hexo</span></span><br><span class="line">	<span class="comment">#	 因为 nginx.conf 里配置过, 所以 /usr/share/nginx/hexo 就会被 nginx 作为静态资源代理展示</span></span><br></pre></td></tr></tbody></table></figure></div>
<h1 id="3、部署"><a href="#3、部署" class="headerlink" title="3、部署"></a>3、部署</h1><h2 id="3-1、打开-hexo-主目录，可以看到编译出来的-public-文件夹"><a href="#3-1、打开-hexo-主目录，可以看到编译出来的-public-文件夹" class="headerlink" title="3.1、打开 hexo 主目录，可以看到编译出来的 public 文件夹"></a>3.1、打开 <code>hexo</code> 主目录，可以看到编译出来的 <code>public</code> 文件夹</h2><p><a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20200807142639863.png#pic_center" data-fancybox="group" data-caption="在这里插入图片描述" class="fancybox"><img alt="在这里插入图片描述" title="在这里插入图片描述" data-src="https://img-blog.csdnimg.cn/20200807142639863.png#pic_center" class="lazyload"></a></p>
<h2 id="3-2、上传"><a href="#3-2、上传" class="headerlink" title="3.2、上传"></a>3.2、上传</h2><p>使用 <code>scp</code> 工具将 <code>public</code> 文件夹上传到 <code>/usr/doc/nginx/hexo/</code> 下</p>
<div class="code-area-wrap"><div class="highlight-tools"><i class="fa fa-angle-down code-expand" aria-hidden="true"></i><div class="code_lang">bash</div></div><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># scp 格式</span></span><br><span class="line">scp 本地文件路径 服务器用户名@服务器域名或IP地址:服务器目录 		<span class="comment"># 上传文件</span></span><br><span class="line">scp -r 本地文件夹路径 服务器用户名@服务器域名或IP地址:服务器目录	<span class="comment"># 上传文件夹</span></span><br></pre></td></tr></tbody></table></figure></div>
<p>如下：<br><a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20200807142733388.png#pic_center" data-fancybox="group" data-caption="在这里插入图片描述" class="fancybox"><img alt="在这里插入图片描述" title="在这里插入图片描述" data-src="https://img-blog.csdnimg.cn/20200807142733388.png#pic_center" class="lazyload"></a><br>回到服务器中查看 <code>/usr/doc/nginx/hexo/public</code> 就会有上传的内容了<br><a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20200807143108591.png#pic_center" data-fancybox="group" data-caption="在这里插入图片描述" class="fancybox"><img alt="在这里插入图片描述" title="在这里插入图片描述" data-src="https://img-blog.csdnimg.cn/20200807143108591.png#pic_center" class="lazyload"></a></p>
<h1 id="结束"><a href="#结束" class="headerlink" title="结束"></a>结束</h1><p>至此，读者便可访问自己服务器了，如我的域名为 <code>cying.io</code>，<code>nginx</code> 暴露的端口为 <code>81</code>，所以在浏览器地址栏输入 <code>cying.io:81</code> 即可访问<br><a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20200807143430719.png#pic_center" data-fancybox="group" data-caption="在这里插入图片描述" class="fancybox"><img alt="在这里插入图片描述" title="在这里插入图片描述" data-src="https://img-blog.csdnimg.cn/20200807143430719.png#pic_center" class="lazyload"></a><br>与 <a href="https://cyingk.github.io">Github 博客</a> 的访问效果是一样的<br><a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20200807143612104.png#ic_center" data-fancybox="group" data-caption="在这里插入图片描述" class="fancybox"><img alt="在这里插入图片描述" title="在这里插入图片描述" data-src="https://img-blog.csdnimg.cn/20200807143612104.png#ic_center" class="lazyload"></a><br>最后，读者可以在 <code>hexo</code> 项目的跟目录下写一个 <code>upload.bat</code> 脚本文件，免得每次手动写 <code>scp</code> 命令，如：</p>
<div class="code-area-wrap"><div class="highlight-tools"><i class="fa fa-angle-down code-expand" aria-hidden="true"></i><div class="code_lang">bat</div></div><figure class="highlight bat"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">scp -r public root@Cying.io:/usr/doc/nginx/hexo/</span><br></pre></td></tr></tbody></table></figure></div></body></html></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">Author: </span><span class="post-copyright-info"><a href="mailto:undefined">Cying-承影</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">Link: </span><span class="post-copyright-info"><a href="http://cyingk.github.io/2020/08/07/Hexo-To-Own-Server/">http://cyingk.github.io/2020/08/07/Hexo-To-Own-Server/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/NodeJs/">NodeJs</a></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="next-post pull-full"><a href="/2020/08/06/Linux-And-Docker/"><img class="next-cover" src="https://img-blog.csdnimg.cn/202008061653587.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">Next Post</div><div class="next_info">SpringCloud With Docker</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1%E3%80%81%E5%89%8D%E6%9C%9F%E5%87%86%E5%A4%87"><span class="toc-number">1.</span> <span class="toc-text">1、前期准备</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2%E3%80%81%E5%AE%B9%E5%99%A8%E5%88%9D%E5%A7%8B%E5%8C%96%EF%BC%88%E8%AF%B7%E5%85%88%E5%AE%89%E8%A3%85-docker%EF%BC%89"><span class="toc-number">2.</span> <span class="toc-text">2、容器初始化（请先安装 docker）</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#2-1%E3%80%81%E6%8B%89%E5%8F%96%E9%95%9C%E5%83%8F"><span class="toc-number">2.1.</span> <span class="toc-text">2.1、拉取镜像</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2%E3%80%81%E5%88%9B%E5%BB%BA%E5%AE%B9%E5%99%A8"><span class="toc-number">2.2.</span> <span class="toc-text">2.2、创建容器</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3%E3%80%81%E9%83%A8%E7%BD%B2"><span class="toc-number">3.</span> <span class="toc-text">3、部署</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#3-1%E3%80%81%E6%89%93%E5%BC%80-hexo-%E4%B8%BB%E7%9B%AE%E5%BD%95%EF%BC%8C%E5%8F%AF%E4%BB%A5%E7%9C%8B%E5%88%B0%E7%BC%96%E8%AF%91%E5%87%BA%E6%9D%A5%E7%9A%84-public-%E6%96%87%E4%BB%B6%E5%A4%B9"><span class="toc-number">3.1.</span> <span class="toc-text">3.1、打开 hexo 主目录，可以看到编译出来的 public 文件夹</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-2%E3%80%81%E4%B8%8A%E4%BC%A0"><span class="toc-number">3.2.</span> <span class="toc-text">3.2、上传</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%BB%93%E6%9D%9F"><span class="toc-number">4.</span> <span class="toc-text">结束</span></a></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="footer_custom_text">却道天凉好个秋</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="Increase font size"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="Decrease font size"><i class="fas fa-minus"></i></button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="Back To Top"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>